package com.ruoyi.gybj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gybj.domain.StrategyMessageField;
import com.ruoyi.gybj.service.IStrategyMessageFieldService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 策略消息字段Controller
 * 
 * @author ruoyi
 * @date 2025-11-19
 */
@RestController
@RequestMapping("/message/strategyField")
public class StrategyMessageFieldController extends BaseController
{
    @Autowired
    private IStrategyMessageFieldService strategyMessageFieldService;

    /**
     * 查询策略消息字段列表
     */
    @PreAuthorize("@ss.hasPermi('message:strategyField:list')")
    @GetMapping("/list")
    public TableDataInfo list(StrategyMessageField strategyMessageField)
    {
        startPage();
        List<StrategyMessageField> list = strategyMessageFieldService.selectStrategyMessageFieldList(strategyMessageField);
        return getDataTable(list);
    }

    /**
     * 导出策略消息字段列表
     */
    @PreAuthorize("@ss.hasPermi('message:strategyField:export')")
    @Log(title = "策略消息字段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StrategyMessageField strategyMessageField)
    {
        List<StrategyMessageField> list = strategyMessageFieldService.selectStrategyMessageFieldList(strategyMessageField);
        ExcelUtil<StrategyMessageField> util = new ExcelUtil<StrategyMessageField>(StrategyMessageField.class);
        util.exportExcel(response, list, "策略消息字段数据");
    }

    /**
     * 获取策略消息字段详细信息
     */
    @PreAuthorize("@ss.hasPermi('message:strategyField:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(strategyMessageFieldService.selectStrategyMessageFieldById(id));
    }

    /**
     * 新增策略消息字段
     */
    @PreAuthorize("@ss.hasPermi('message:strategyField:add')")
    @Log(title = "策略消息字段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StrategyMessageField strategyMessageField)
    {
        return toAjax(strategyMessageFieldService.insertStrategyMessageField(strategyMessageField));
    }

    /**
     * 修改策略消息字段
     */
    @PreAuthorize("@ss.hasPermi('message:strategyField:edit')")
    @Log(title = "策略消息字段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StrategyMessageField strategyMessageField)
    {
        return toAjax(strategyMessageFieldService.updateStrategyMessageField(strategyMessageField));
    }

    /**
     * 删除策略消息字段
     */
    @PreAuthorize("@ss.hasPermi('message:strategyField:remove')")
    @Log(title = "策略消息字段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(strategyMessageFieldService.deleteStrategyMessageFieldByIds(ids));
    }
}
